import axios from 'axios'

// 创建一个axios对象
const instance = axios.create({
  baseURL: 'http://localhost:3007',
  timeout: 500
})

instance.interceptors.request.use(
  config => {
    const token = localStorage.getItem('token')
    if(token && token !== '') {
      config.headers['token'] = token
    }
    return config
  },
  error => {
    console.log(err)
    return Promise.reject(error)
  }
)

// export function get(url, params) {
//   return instance.get(url, {
//     params
//   })
// }

// export function post(url, data) {
//   console.log(data, 'axios post----')
//   return instance.post(url, data)
// }

// export function del(url) {
//   return instance.delete(url)
// }

// export function put(url, data) {
//   return instance.put(url, data)
// }

